import 'package:get/get.dart';
import 'package:safetymonitor/app/components/custom_refresh.dart';
import 'package:safetymonitor/app/core/core.dart';
import 'package:safetymonitor/app/core/http/http.dart';
import 'package:safetymonitor/app/core/utils/interface.dart';
import 'package:safetymonitor/app/data/entities/home/enterprise/enterprise_information_get_entity.dart';
import 'package:safetymonitor/modules/home/enterprise/a_enterprise_controller.dart';

///企业基本信息
class CompanyInfoController extends GetxController {
  /// 列表刷新key
  final GlobalKey<CustomEasyRefreshListState> globalKey = GlobalKey();

  EnterpriseInformationGetEntity? data;

  @override
  void onInit() {
    super.onInit();
    //获得企业基本信息
    information();
  }
  bool isNotPermissions=true;
  ///获得企业基本信息
  void information() async {
    final res = await HttpUtil().generateGetRequest<EnterpriseInformationGetEntity>(
      Interface.enterpriseInformationGet,
      queryParameters: {
        'companyName': Get.find<EnterpriseController>().selectCompany, // 化学分公司
      },
    ).execute();
    res.onSuccess((result) {
      if (result.data != null) {
        data = result.data!;
      }
      isNotPermissions=true;
    });
    res.onError((result) {
      if(result.code==403&&result.message=='没有该操作权限'){
        isNotPermissions=false;
        update();
      }
    });
    update();
  }
}
